﻿@model GameSchoolApplication.Models.ViewModels.ExamModel
<input type="hidden" id="navString" value="exam" />
<input type="hidden" id="ID" value="@Model.examID" />

<div id="examHeader" >
    <input type="hidden" id="examID" value="@Model.examID" />
    <input type="hidden" id="questionCount" value="@Model.qList.Count()" />
    <label>@Model.eTitle</label>
    <p>@Model.exDesc</p>    
</div>
<div id="examBody">
    @foreach (var q in Model.qList)
    {
        <div class="examQuestion">
            <p class="questionText">@q.qText</p>
            @foreach (var qo in q.optionList)
            {
                <input type="radio" name="@q.qID" value="@qo.Key" />@qo.Value<br />
            }
        </div>
    }
    <input type="button" id="submitTest" value="Skila prófi" />
</div>
<script type="text/javascript">
    $("#submitTest").click(function () {
        var examID = $("#examID").val();
        var qCount = $("#questionCount").val();
        var answerList = new Array(qCount);
        for (var x = 0; x < qCount; x++) {
            answerList[x] = $("input[@@name=" + (x + 1) + "]:checked").val()
        }
        var param = { examID: examID, answerList: answerList }
        $.getJSON("Exam/turnInExam", param, function (data) {
            window.location.href = "viewResult?examID=" + examID;
        });
    });
        
</script>